#!/usr/bin/python
#-*-coding:utf-8-*-

from sqlalchemy import Column, String, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# 创建对象的基类:
Base = declarative_base()

# 定义User对象:
class Notice(Base):
    # 表的名字:
    __tablename__ = 'notice'

    # 表的结构:
    id = Column(Integer, primary_key=True)
    title = Column(String(255))

# 初始化数据库连接:
#mysql+mysqldb://root:123@localhost/ooxx?charset=utf8'
engine = create_engine('mysql+mysqldb://superadmin:AdminSuper@101.200.213.220:3306/merge_data')
# 创建DBSession类型:
DBSession = sessionmaker(bind=engine)


session = DBSession()
# 创建新User对象:
new_user = Notice( title='asfasdfasdfasdf')
# 添加到session:
session.add(new_user)
# 提交即保存到数据库:
session.commit()
# 关闭session:
session.close()